package kuzmenkov.oip.controller.applet;

import java.awt.FlowLayout;
import java.awt.geom.Rectangle2D;

import javax.swing.JLabel;

/**
 * An UI component that is responsible for an area selection. It extracts 
 * an area selection from a selectable component
 * @author Michael Kuzmenkov
 *
 */
public class SelectionUIC extends ParamUIC{

	/**
	 * 
	 */
	private static final long serialVersionUID = 8987077125236115589L;
	/**
	 * An UI component that supports a selection
	 */
	private ISelectableUIC selectableUIC;
	
	protected SelectionUIC(Param param, ISelectableUIC uic) {
		super(param);
		this.selectableUIC = uic;
		init();
	}
	
	private void init() {
		Param param = getParam();
		String name = param.getName();
		//boolean isResult = param.isResult();//TODO
		String tip = I18nTool.getInstance().getMessage("selectionTip");
		

		JLabel label = new JLabel(name);
		label.setToolTipText(tip);
		
		//JLabel label2 = new JLabel("");//TODO

		setLayout(new FlowLayout(FlowLayout.LEFT));
		
		add(label);
		
	}

	public Object getValue() {
		
		return selectableUIC.getSelection();
	}

	public void setValue(Object object) {
		selectableUIC.setSelection((Rectangle2D)object);
		
	}

}
